<template>
    <!-- 外层框架，设置margin-top -->
    <div class="section-margin-top">
        <!-- 设置红色背景图 -->
        <div class="hotTop">
            <!-- 框架 -->
            <div class="hotopct">
                <!-- 设置热歌榜背景图 -->
                <div class="hoticon">

                </div>
                <div class="hotTime">
                    更新日期：{{setTime()}}
                </div>  
            </div>
        </div>
        <div class="Song">
            <music v-for="(item,index) in hotSongList" :key="item.id" v-bind="item" :index="index"></music>
            <div class="hotdn"><span>查看完整榜单</span></div>
        </div>
    </div>
</template>
<script>
import music from '@/components/music-T'
import axios from 'axios'
import api from '@/api/index.js'
export default {
    data(){
        return {
            hotSongList:[],
            time:Number
        }
    },
    components:{
        music
    },
    methods:{
        getHotSongData(){
            axios.get(api.hotSong)
            .then((res)=>{
                console.log(res)
                this.hotSongList=(res.data.playlist.tracks).splice(0,20);
                this.time=res.data.playlist.updateTime;
            })
        },
        setTime(){
             var T=new Date(this.time);
             var month=T.getMonth()+1;
             var day=T.getDate();
             return month+"月"+day+"日";
            
        }
    },
    mounted(){
        this.getHotSongData()
    }
}
</script>
<style lang="scss" scoped>
.section-margin-top{
    margin-top: 105px;
    background-color: #fcfcfd;
    .hotTop{
        position: relative;
        padding-top: 38.9%;
        background: url(//s3.music.126.net/m/s/img/hot_music_bg_2x.jpg?f01a252…) no-repeat;
        background-size: contain;
        overflow: hidden;
        .hotopct{
            display: -webkit-box;
            display: -webkit-flex;
            display: flex;
            -webkit-box-orient: vertical;
            -webkit-box-direction: normal;
            -webkit-flex-direction: column;
            flex-direction: column;
            -webkit-box-pack: center;
            -webkit-justify-content: center;
            justify-content: center;
            z-index: 2;
            padding-left: 20px;
            box-sizing: border-box;
            position: absolute;
            left: 0;
            top: 0;
            right: 0;
            bottom: 0;
            .hoticon{
                width: 142px;
                height: 67px;
                background: url(//s3.music.126.net/m/s/img/index_icon_2x.png?5207a28…) no-repeat;
                background-size: 166px 97px;
                background-position: -24px -30px;
            }
            .hotTime{
                margin-top: 10px;
                color: hsla(0,0%,100%,.8);
                font-size: 12px;
                -webkit-transform: scale(.91);
                transform: scale(.91);
                -webkit-transform-origin: left top;
                transform-origin: left top;
            }
        }
    }
    .hotdn{
        height: 55px;
        line-height: 55px;
        text-align: center;
        span{
        display: inline-block;
        color: #999;
        padding-right: 14px;
        background: url() 100% no-repeat;
       
        background-position-x: 100%;
        background-position-y: center;
        background-size: 7px 12px;
        background-repeat-x: no-repeat;
        background-repeat-y: no-repeat;
        background-attachment: initial;
        background-origin: initial;
        background-clip: initial;
        background-color: initial;
        background-size: 7px 12px;
        }
    }
}
</style>
